<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateApiKeysTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('api_keys', function (Blueprint $table) {
            $table->bigIncrements('id');                //apikey的id
            $table->bigInteger('customer_id');          // 所属用户的id
            $table->string('key')
                  ->unique()
                  ->index();                            // apikey的key
            $table->string('secret');                   // apikey的secret
            $table->string('name');                     // apikey的名称
            $table->string('description');              // apikey的描述
            $table->string('status')->default('normal');// apikey的状态:nomal--正常,user-locked--用户锁定，admin-locked--管理员锁定
            $table->softDeletes();                      // 软删除时间
            $table->timestamps();                       // apikey的时间戳
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('api_keys');
    }
}
